@extends('admin')

@section('content')

    <p class="mb10">
        <a href="{{url('admin/product/updatet')}}" class="btn J_dialog" title="添加类别"><span class="add"></span>添加类别</a>
    </p>

    <div class="h_a">搜索</div>
    <div class="search_type cc mb10">
        <form action="{{url('admin/product/type')}}" method="get" class="search_form">
            <label for="search_name">类别名称：</label>
            <input type="text" name="name" value="{{isset($appends['name']) ? $appends['name'] : ""}}" id="search_name"
                   class="input length_2 mr10"/>
            <select name="parent_id">
                <option value="0" {{!isset($appends['parent_id']) || 0 == $appends['parent_id'] ? 'selected="selected"' : ''}}>所有类别</option>
                @foreach($parents as $key=>$parent)
                    <option value="{{$key}}" {{isset($appends['parent_id']) && $key == $appends['parent_id'] ? 'selected="selected"' : ''}}>{{$parent}}</option>
                @endforeach
            </select>
            <button type="submit" class="btn">提交查询</button>
        </form>

    </div>

    <div class="table_list">
        <div id="data_list">
            <table class="items">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>中文名称</th>
                    <th>类别名称</th>
                    <th>父级类别</th>
                    <th>排序</th>
                    <th>发布者</th>
                    <th>备注</th>
                    <th>发布时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($list as $item)
                    <tr>
                        <td>{{$item->id}}</td>
                        <td>{{$item->name_cn}}</td>
                        <td>{{$item->name}}</td>
                        <td>{{0 != $item->parent_id ? $item->parent->name : "顶级分类"}}</td>
                        <td>{{$item->range}}</td>
                        <td>{{$item->poster->nick}}</td>
                        <td>{{$item->description_cn}}</td>
                        <td>{{$item->created_at}}</td>
                        <td>
                            <a href="{{url('admin/product/updatet/'.$item->id)}}" title="编辑 {{$item->name}}"
                               class="mr10 J_dialog">[编辑]</a>
                            <a href="{{url('admin/product/deletet/'.$item->id)}}" class="mr10 J_ajax_del">[删除]</a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>

        <div class="summary">
            共有 {{$list->total()}} 条数据
        </div>
        @if ($list->hasPages())
            <div class="pager">
                {!! $list->appends($appends)->render() !!}
            </div>
        @endif
    </div>

@stop